﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>培训计划内容</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../../static/css/font.css">
    <link rel="stylesheet" href="../../../static/css/weadmin.css">
    <style type="text/css">
        .layui-card {
            margin-bottom: 0px;
        }

        .layui-card-header {
            border: 1px solid #f6f6f6;
            font-weight: bold;
        }

        .layui-table, .layui-table-view {
            margin: 0px;
        }

        .layui-form-checkbox[lay-skin=primary] {
            padding-left: 0px;
        }

        .longtext {
            text-overflow: ellipsis;
            overflow: hidden;
            white-space: nowrap;
        }
    </style>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
    <div class="weadmin-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <label for="TPName" class="layui-form-label">
                    <span class="we-red"></span>计划名称
                </label>
                <div class="layui-input-inline" contenteditable="false">
                    <input id="TPName" name="TPName" class="layui-input" contenteditable="false" width="300">
                </div>
                <label for="TPDescribe" class="layui-form-label">
                    <span class="we-red"></span>计划描述
                </label>
                <div class="layui-input-inline">
                    <input id="TPDescribe" name="TPDescribe" class="layui-input" width="400">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="TTID" class="layui-form-label">
                    <span class="we-red"></span>内容类型
                </label>
                <div class="layui-input-inline">
                    <select lay-filter="TTID" id="TTID" name="TTID" class="valid">
                        <option value=""></option>
                        <option value="0">文件</option>
                        <option value="1">试卷</option>
                        <option value="2">试题</option>
                    </select>
                </div>
                <label for="TCName" class="layui-form-label">
                    <span class="we-red"></span>内容名称/描述:
                </label>
                <div class="layui-input-inline">
                    <input id="TCName" name="TCName" contenteditable="false" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="TCIntegral" class="layui-form-label">
                    <span class="we-red"></span>单个积分
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="TCIntegral" name="TCIntegral" autocomplete="off" class="layui-input" value="1">
                </div>
                <label for="TCScore" class="layui-form-label">
                    <span class="we-red"></span>总积分
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="TCScore" name="TCScore" autocomplete="off" class="layui-input">
                </div>
                <div class="layui-btn-container">
                    <button class="layui-btn layui-btn-sm" id="btnSave"><i class="layui-icon"> </i>添加保存</button>
                </div>
            </div>
        </form>

        <table id="datalist" lay-filter="datalist"></table>

    </div>
    <script src="../../../lib/layui/layui.js" charset="utf-8"></script>
    <script src="../../../static/js/common.js" charset="utf-8"></script>
    <script type="text/html" id="toolbar">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="delAll"><i class="layui-icon"></i>批量删除</button>
            <button class="layui-btn layui-btn-sm" lay-event="add"><i class="layui-icon"></i>添加</button>
            <label for="TTID" class="layui-form-label">
                <span class="we-red"></span>内容类型
            </label>
            <div class="layui-input-inline">
                <select lay-filter="TTID" id="TTID" name="TTID" class="valid">
                    <option value=""></option>
                    <option value="0">文件</option>
                    <option value="1">试卷</option>
                    <option value="2">试题</option>
                </select>
            </div>
        </div>
    </script>
    <!--<script type="text/html" id="tool">
        <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
        <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>-->
    <script>
        layui.use(['table', 'jquery', 'layer', 'form'], function () {
            var table = layui.table,
                $ = layui.jquery,
                form = layui.form,
                layer = layui.layer;

            var TPID = getUrlParam("TPID");
            var TPName = getUrlParam("TPName");
            var TPDescribe = getUrlParam("TPDescribe");
            //$("#TPName") = TPName;
            //$("#TPDescribe").val() = TPName;
            document.getElementById('TPName').value = TPName;
            document.getElementById('TPDescribe').value = TPDescribe;
            var plancontext, curtype,strtemp = "";
            table.on('checkbox(datalist)', function (obj) {
                if (obj.type == "all") {
                    for (var i = 0; i < table.cache.datalist.length; i++) {
                        if (curtype == 0)
                            strtemp = curtype + ',' + table.cache.datalist[i].TFID + '|';
                        else if (curtype == 1)
                            strtemp = curtype + ',' + table.cache.datalist[i].EPID + '|';
                        else if (curtype == 2)
                            strtemp = curtype + ',' + table.cache.datalist[i].EQID + '|';
                        plancontext = plancontext.replace(strtemp, "");
                    }
                    var checkStatus = table.checkStatus('datalist');
                    for (var j = 0; j < checkStatus.data.length; j++) {
                        if(curtype == 0)
                            strtemp = curtype + ',' + checkStatus.data[j].TFID + '|';
                        if (curtype == 1)
                            strtemp = curtype + ',' + checkStatus.data[j].EPID + '|';
                        if (curtype == 2)
                            strtemp = curtype + ',' + checkStatus.data[j].EQID + '|';
                        plancontext += strtemp;
                    }
                }
                if (obj.type == "one") {
                    if (obj.checked) {
                        if (curtype == 0)
                            plancontext += curtype + ',' + obj.data.TFID + '|';
                        if (curtype == 1)
                            plancontext += curtype + ',' + obj.data.EPID + '|';
                        if (curtype == 2)
                            plancontext += curtype + ',' + obj.data.EQID + '|';
                    }
                    else {
                        var str1 = '';
                        if (curtype == 0)
                        //'asdfasdfasdadas'.replace(new RegExp("as", "g"), "tt")
                        {
                            str1 = curtype + ',' + obj.data.TFID + '|';
                        }
                        if (curtype == 1) {
                            str1 = curtype + ',' + obj.data.EPID + '|';
                        }
                        if (curtype == 2) {
                            str1 = curtype + ',' + obj.data.EQID + '|';
                        }
                        plancontext = plancontext.replace(str1, "");
                    }
                }
                
                console.log(plancontext);

                document.getElementById('TCScore').value = plancontext == "" ? "0" : (parseFloat($("#TCIntegral").val()) * plancontext.split('|').length-1).toString();

            });
            function replacestr (reallyDo, replaceWith, ignoreCase) {
                if (!RegExp.prototype.isPrototypeOf(reallyDo)) {
                    return this.replace(new RegExp(reallyDo, (ignoreCase ? "gi" : "g")), replaceWith);
                } else {
                    return this.replace(reallyDo, replaceWith);
                }
            }
            $.ajaxSetup({
                cache: false,
                headers: {
                    "userid": JSON.parse(window.localStorage.authInfo).UserId,
                    "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                },
            })
            var depdata = {};
            $.ajax({
                url: ApiUrl + "Dep/Sel",
                type: 'post',
                success: function (data) {
                    if (data.StatusCode == 200) {
                        //depdata = data.Data;
                        $.each(data.Data, function (index, item) {
                            depdata[item.DepID] = item.DepName;
                        })
                    }
                },
            });


            function getFileList() {
                var swhere = JSON.stringify({
                    //TFName: $("#sTFName").val().trim(),
                    //TFAddUserName: $("#sTFAddUserName").val(),
                    //TFUploadDeptID: $("#DepID").val(),
                    //start: $("#start").val().trim(),
                    end: new Date(),
                    TFIsUse: 1,
                    TFIsPass: 1,
                });
                table.render({
                    id: "datalist",
                    elem: '#datalist',
                    url: ApiUrl + 'TrainFiles/Search', //数据接口,
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    where: { swhere: swhere },
                    cellMinWidth: 60,
                    //toolbar: "#toolbar",
                    cols: [
                        [
                            { type: 'checkbox' },
                            { field: 'TFID', title: '编号', sort: true, hide: true },
                            { field: 'KKName', title: '知识点' },
                            { field: 'FTName', title: '文件类型' },
                            { field: 'TFName', title: '文件名称' },
                            { field: 'TFFileLevel', title: '重要等级' },
                            { field: 'TFPath', title: '文件位置', hide: true },
                            { field: 'TFSize', title: '文件大小', hide: true },
                            { field: 'TFAddUserName', title: '上传人', hide: true  },
                            { field: 'TFAddDateTime', title: '上传时间', hide: true },
                            { field: 'DepName', title: '所属部门', hide: true  },
                            { field: 'TFUseCount', title: '下载次数', hide: true },
                            { field: 'IsPass', title: '是否审批' },
                            { field: 'IsDelete', title: '是否删除', hide: true }
                            //{ fixed: 'right', title: '操作', align: 'center', toolbar: '#tool', width: 162, }
                        ]
                    ],
                    parseData: function (res) { //res 即为原始返回的数据
                        return {
                            "code": res.StatusCode, //解析接口状态
                            "msg": res.Info, //解析提示文本
                            "count": res.Count, //解析数据长度
                            "data": res.Data //解析数据列表
                        };
                    },
                    response: { statusCode: 200 },//规定成功的状态码，默认：0
                    event: true,
                    page: true,
                    done: function (res, curr, count) {
                        //如果是异步请求数据方式，res即为你接口返回的信息。
                        //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度 
                        if (res.code == 403) {
                            layer.alert(res.msg, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                    }
                });
            };
            //获取部门名称
            function GetDepNames(depids) {
                var depNames = "";
                $.each(depids.split(','), function (index, item) {
                    depNames += depdata[item] + ",";
                })
                return depNames.substring(0, depNames.length > 0 ? depNames.length - 1 : 0);
            }
            function getPaperList() {

                var swhere = JSON.stringify({
                    EPIsRelease: 1,
                });

                table.render({
                    id: "datalist",
                    elem: '#datalist',
                    url: ApiUrl + 'ExamPaperMain/Search', //数据接口,
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    where: {
                        swhere: swhere
                    },
                    cellMinWidth: 80,
                    //toolbar: "#toolbar",
                    cols: [
                        [
                            { type: 'checkbox' },
                            { field: 'EPID', title: '编号', sort: true, hide: true },
                            { field: 'EPName', title: '名称' },
                            //{ field: 'EPTID', title: '类型'},
                            { field: 'EPTName', title: '类型' },
                            { field: 'EPFullMarks', title: '满分', hide: true },
                            {
                                field: 'DepIDs', title: '考试部门', templet: function (d) {
                                    return GetDepNames(d.DepIDs);
                                }
                            },
                            { field: 'EPExamDuration', title: '时长(分)', hide: true },
                            { field: 'EPDescribe', title: '描述', hide: true },
                            { field: 'EPRoom', title: '考场' },
                            //{ field: 'EPIsRelease', title: '在发布' },
                            {
                                field: 'EPIsRelease', title: '在发布', templet: function (d) {
                                    return d.EPIsRelease == "0" ? "否" : "是";
                                }, hide: true
                            },
                            //{ field: 'EPStartTime', title: '开始时间' },
                            {
                                field: 'EPStartTime', title: '开始时间', templet: function (d) {
                                    return d.EPStartTime.substring(0, 10);
                                }, hide: true
                            },
                            //{ field: 'EPEndTime', title: '结束时间' },
                            {
                                field: 'EPEndTime', title: '结束时间', templet: function (d) {
                                    return d.EPEndTime.substring(0, 10);
                                }, hide: true
                            },
                            { field: 'EPExaminer', title: '监考人', hide: true },
                            //{ field: 'EPAddEmpID', title: '创建者' },
                            { field: 'EPAddEmpName', title: '创建者', hide: true },
                            { field: 'EPAddDateTime', title: '创建时间', hide: true }
                            //{ fixed: 'right', title: '操作', align: 'center', toolbar: '#tool', width: 236, }
                        ]
                    ],
                    parseData: function (res) { //res 即为原始返回的数据
                        return {
                            "code": res.StatusCode, //解析接口状态
                            "msg": res.Info, //解析提示文本
                            "count": res.Count, //解析数据长度
                            "data": res.Data //解析数据列表
                        };
                    },
                    response: { statusCode: 200 },//规定成功的状态码，默认：0
                    event: true,
                    page: true,
                    done: function (res, curr, count) {
                        //如果是异步请求数据方式，res即为你接口返回的信息。
                        //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度 
                        if (res.code == 403) {
                            layer.alert(res.msg, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                    }
                });
                
            }; 
            function getQuestionList() {
                var swhere = "";
                //    EQID = $("#EQID").val().trim(),
                //    ETID = $("#ETID").val();
                //var ETText = $("#ETID").find("option:selected").text();
                //if (EQID != "") { swhere += " and EQID='" + EQID + "' "; }
                //if (null != ETID) {
                //    if (ETID != "" && ETText != '请选择') { swhere += "and  ETID='" + ETID + "' "; }
                //}
                table.render({
                    id: "datalist",
                    elem: '#datalist',
                    url: ApiUrl + 'ExamQuestions/SelListPage', //数据接口,
                    where: { swhere: swhere },
                    cellMinWidth: 80,
                    //toolbar: "#toolbar",
                    cols: [
                        [
                            { type: 'checkbox' },
                            { field: 'EQID', title: '试题编号', sort: true, hide: true },
                            { field: 'KKName', title: '知识点' },
                            { field: 'ETName', title: '试题类型' },
                            { field: 'EQContent', title: '问题' },
                            { field: 'EQAnswer', title: '答案', hide: true },
                            { field: 'EQScore', title: '试题分数' },
                            { field: 'EQIntegral', title: '积分', hide: true }
                        ]
                    ],
                    parseData: function (res) { //res 即为原始返回的数据
                        return {
                            "code": res.StatusCode, //解析接口状态
                            "msg": res.Info, //解析提示文本
                            "count": res.Count, //解析数据长度
                            "data": res.Data //解析数据列表
                        };
                    },
                    response: { statusCode: 200 },//规定成功的状态码，默认：0
                    event: true,
                    page: true,
                    done: function (res, curr, count) {
                        //如果是异步请求数据方式，res即为你接口返回的信息。
                        //如果是直接赋值的方式，res即为：{data: [], count: 99} data为当前页数据、count为数据总长度 
                        if (res.code == 403) {
                            layer.alert(res.msg, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                    }
                });
            }



            $(function () {
                form.on('select(TTID)', function (data) {
                    //console.log(data);
                    //console.log(data.value);
                    plancontext = "";
                    if (data.value == 0)
                        getFileList();
                    else if (data.value == 1)
                        getPaperList();
                    else if (data.value == 2)
                        getQuestionList();
                    curtype = data.value;
                });
            });

             //保存内容
            $("#btnSave").click(function () {
                if (isNaN(plancontext)) {
                    layer.alert("请选择培训内容");
                    return;
                }
                if ( plancontext.split('|').length - 1 <= 0) {
                    layer.alert("请选择培训内容");
                    return;
                }

                //if ($('#showEPFullMarks').html() != $('#showCheckedZf').html()) {
                //    layer.alert("已选总分和试卷要求总分不匹配，请重新选题");
                //    return;
                //}
                //var eqids = "";
                //$('#list2 tbody tr').each(function (item) {
                //    eqids += $(this).data("eqid") + "-" + $(this).data("etorder")  + "|";
                //})
                //eqids = eqids.substring(0, eqids.length - 1);

                var dataval = JSON.stringify({ PlanContext: plancontext, TPID: TPID, TTID: curtype, TCName: $("#TCName").val(), TCIntegral: $("#TCIntegral").val(), TCScore: $("#TCScore").val() } );
                console.log(dataval);
                $.ajax({
                    url: ApiUrl + "TrainContent/Add",
                    type: 'post',
                    cache: false,
                    contentType: 'application/json',//dynamic接收参数时需要加上此行
                    headers: {
                        "userid": JSON.parse(window.localStorage.authInfo).UserId,
                        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
                    },
                    data: dataval,
                    success: function (data) {
                        if (data.StatusCode == 200) {
                            console.log(data)
                            layer.alert("保存成功", { icon: 6 }, function (index) {
                                //parent.layer.closeAll();
                            })
                        }
                        else if (data.StatusCode == 403) {
                            top.layer.alert(data.Info + ",请重新登录！", { closeBtn: 0 }, function () {
                                top.location.href = "http://" + top.location.host + "/login.html";
                            })
                        }
                        else {
                            layer.msg(data.Info);
                        }
                    }
                });
            })

            //var allTrs;//存储所有试题信息，查询时不再请求api
            //$("#loadlist,#loadlist2").css("height", $("body").height() - 58 - 46);
            ////试卷ID
            //var epid = getUrlParam("ID");
            ////知识点列宽度，用于超出列宽以...显示
            //var zsdwidth = $("#list2 thead tr:first th:eq(4)").width();
            ////获取试卷信息
            //$.ajax({
            //    url: ApiUrl + "ExamPaperMain/GetSingle",
            //    type: 'get',
            //    cache: false,
            //    headers: {
            //        "userid": JSON.parse(window.localStorage.authInfo).UserId,
            //        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
            //    },
            //    data: { id: getUrlParam("ID"), fields:"EPFullMarks" },
            //    success: function (data) {
            //        if (data.StatusCode == 200) {
            //            $("#showEPFullMarks").html(data.Data[0].EPFullMarks);
            //            $("#showDepNames").html(data.Data[0].DepNames);
            //        }
            //        else if (data.StatusCode == 403) {
            //            top.layer.alert(data.Info + ",请重新登录！", { closeBtn: 0 }, function () {
            //                top.location.href = "http://" + top.location.host + "/login.html";
            //            })
            //        }
            //        else {
            //            layer.msg(data.Info);
            //        }
            //    }
            //});
            ////加载全部试题
            //var listajax = $.ajax({
            //    url: ApiUrl + "ExamQuestions/SelListForSelQuestion",
            //    type: 'get',
            //    cache: false,
            //    headers: {
            //        "userid": JSON.parse(window.localStorage.authInfo).UserId,
            //        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
            //    },
            //    //data: { EPID: getUrlParam("ID") },
            //    success: function (data) {
            //        if (data.StatusCode == 200) {
            //            //加载已选试题表格
            //            $(data.Data).each(function (index, item) {
            //                $("#list tbody").append(GetHtmlStr(item, false));
            //                allTrs = data.Data;
            //            });
            //            form.render();
            //        }
            //        else if (data.StatusCode == 403) {
            //            top.layer.alert(data.Info + ",请重新登录！", { closeBtn: 0 }, function () {
            //                top.location.href = "http://" + top.location.host + "/login.html";
            //            })
            //        }
            //        else {
            //            layer.msg(data.Info);
            //        }
            //    }
            //});
            ////获取已选试题
            //var checkQuestions;
            //var list2ajax = $.ajax({
            //    url: ApiUrl + "ExamPaperDetail/GetPaperQuestions",
            //    type: 'get',
            //    cache: false,
            //    headers: {
            //        "userid": JSON.parse(window.localStorage.authInfo).UserId,
            //        "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
            //    },
            //    data: { EPID: epid },
            //    success: function (data) {
            //        if (data.StatusCode == 200) {
            //            checkQuestions = data.Data;
            //            //加载已选试题表格
            //            $(data.Data).each(function (index, item) {
            //                $("#list2 tbody").append(GetHtmlStr(item, true));
            //            });
            //            form.render();
            //            SetCheckedInfo();
            //        }
            //        else if (data.StatusCode == 403) {
            //            top.layer.alert(data.Info + ",请重新登录！", { closeBtn: 0 }, function () {
            //                top.location.href = "http://" + top.location.host + "/login.html";
            //            })
            //        }
            //        else {
            //            layer.msg(data.Info);
            //        }
            //    }
            //});
            ////两个表加载完成后，根据已选列表数据，勾选全部试题数据
            //$.when(listajax, list2ajax)
            //    .done(function () {
            //        $(checkQuestions).each(function (index, item) {
            //            $("#cb_" + item.EQID).prop("checked", true);
            //        });
            //        form.render();
            //    });
            ////获取已选题目的数量和总分
            //function SetCheckedInfo() {
            //    var trs = $("#list2 tbody tr");
            //    var ts = trs.length;
            //    var zf = 0;
            //    $(trs).each(function (item) {
            //        zf += $(this).data("eqscore");
            //    });
            //    $("#showCheckedTs").html(ts);
            //    $("#showCheckedZf").html(zf);
            //}
            ////生成表格tr的html
            //function GetHtmlStr(item, ischecked) {
            //    var htmlstr = '<tr id="tr' + (ischecked ? "2" : "") + '_' + item.EQID + '" data-eqid="' + item.EQID + '" data-etname="' + item.ETName + '" data-eqscore="' + item.EQScore + '" data-etorder="' + item.ETOrder + '" data-kkname="' + item.KKName + '">';
            //    htmlstr += '<td><input type="checkbox" ' + (ischecked ? "checked" : "") + ' id="cb' + (ischecked ? "2" : "") + '_' + item.EQID + '" lay-skin="primary" lay-filter="check' + (ischecked ? "2" : "") + '" /></td>';
            //    htmlstr += '<td>' + item.EQID + '</td>';
            //    htmlstr += '<td>' + item.ETName + '</td>';
            //    htmlstr += '<td>' + item.EQScore + '</td>';
            //    htmlstr += '<td><div class="longtext" style="width:' + zsdwidth + 'px" title="' + item.KKName + '">' + item.KKName + '</div></td>';
            //    htmlstr += '</tr>';
            //    return htmlstr;
            //}
            ////监听行单击事件
            //$('#list').on('click', 'tbody tr', function (event) {
            //    //alert($(this).data('eqid'));
            //    //异步请求试题内容及答案，显示到相应位置
            //    $.ajax({
            //        url: ApiUrl + "ExamQuestions",
            //        type: 'get',
            //        cache: false,
            //        contentType: 'application/json',//dynamic接收参数时需要加上此行
            //        headers: {
            //            "userid": JSON.parse(window.localStorage.authInfo).UserId,
            //            "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
            //        },
            //        data: { EQID: $(this).data('eqid') },
            //        success: function (data) {
            //            if (data.StatusCode == 200) {
            //                console.log(data)
            //                $("#showEQContent").html(data.Data.EQContent);
            //                $("#showEQAnswer").html(data.Data.EQAnswer);
            //            }
            //            else if (data.StatusCode == 403) {
            //                top.layer.alert(data.Info + ",请重新登录！", { closeBtn: 0 }, function () {
            //                    top.location.href = "http://" + top.location.host + "/login.html";
            //                })
            //            }
            //            else {
            //                layer.msg(data.Info);
            //            }
            //        }
            //    });

            //    event.stopPropagation();
            //});
            ////监听勾选事件
            //form.on('checkbox(check)', function (data) {
            //    var checkdata = $(data.elem).parent().parent().data();
            //    var checkitem = {
            //        EQID: checkdata.eqid,
            //        ETName: checkdata.etname,
            //        ETOrder: checkdata.etorder,
            //        EQScore: checkdata.eqscore,
            //        KKName: checkdata.kkname
            //    };
            //    //操作list2
            //    if (data.elem.checked) {
            //        $("#list2 tbody").append(GetHtmlStr(checkitem, true));
            //        form.render();
            //    }
            //    else {
            //        $("#tr2_" + checkdata.eqid).remove();
            //    }
            //    //计算已选试题分数等操作
            //    SetCheckedInfo();
            //    //阻止冒泡激发tr事件
            //    var event = event ? event : window.event;
            //    event.stopPropagation();
            //});
            //form.on('checkbox(check2)', function (data) {
            //    var checkdata = $(data.elem).parent().parent().data();
            //    //操作list
            //    if (!data.elem.checked) {
            //        $("#cb_" + checkdata.eqid).prop("checked", false);
            //        $("#tr2_" + checkdata.eqid).remove();
            //        form.render();
            //        SetCheckedInfo();
            //    }
            //});
            ////保存试卷选题
            //$("#btnSave").click(function () {
            //    if ($('#list2 tbody tr').length <= 0) {
            //        layer.alert("请选择试卷试题");
            //        return;
            //    }
            //    if ($('#showEPFullMarks').html() != $('#showCheckedZf').html()) {
            //        layer.alert("已选总分和试卷要求总分不匹配，请重新选题");
            //        return;
            //    }
            //    var eqids = "";
            //    $('#list2 tbody tr').each(function (item) {
            //        eqids += $(this).data("eqid") + "-" + $(this).data("etorder")  + "|";
            //    })
            //    eqids = eqids.substring(0, eqids.length - 1);
            //    $.ajax({
            //        url: ApiUrl + "ExamPaperDetail/UpdatePaperQuestions",
            //        type: 'post',
            //        cache: false,
            //        contentType: 'application/json',//dynamic接收参数时需要加上此行
            //        headers: {
            //            "userid": JSON.parse(window.localStorage.authInfo).UserId,
            //            "signtoken": JSON.parse(window.localStorage.authInfo).SignToken,
            //        },
            //        data: JSON.stringify({ EPID: epid, EQIDS: eqids }),
            //        success: function (data) {
            //            if (data.StatusCode == 200) {
            //                console.log(data)
            //                layer.alert("保存成功", { icon: 6 }, function (index) {
            //                    parent.layer.closeAll();
            //                })
            //            }
            //            else if (data.StatusCode == 403) {
            //                top.layer.alert(data.Info + ",请重新登录！", { closeBtn: 0 }, function () {
            //                    top.location.href = "http://" + top.location.host + "/login.html";
            //                })
            //            }
            //            else {
            //                layer.msg(data.Info);
            //            }
            //        }
            //    });
            //})
            ////查询试题，并在查询后加载勾选已选试题
            //$("#sreach").click(function () {
            //    var stx = $("#stx").val();
            //    var szsd = $("#szsd").val();
            //    if (stx != "" || szsd != "") {
            //        $("#list tbody").html("");
            //        $(allTrs).each(function (index, item) {
            //            if (item.ETName.indexOf(stx) >= 0 && item.KKName.indexOf(szsd) >= 0)
            //                $("#list tbody").append(GetHtmlStr(item, false));
            //        });
            //    }
            //    else {
            //        $("#list tbody").html("");
            //        $(allTrs).each(function (index, item) {
            //            $("#list tbody").append(GetHtmlStr(item, false));
            //        });
            //    }
            //    $($("#list2 tbody tr")).each(function (item) {
            //        $("#cb_" + $(this).data("eqid")).prop("checked", true);
            //    });
            //    form.render();
            //})
        });
    </script>
</body>
</html>